package com.leetcode.dp;

public class NumTrees {
    public static void main(String[] args) {

    }

    public int numTrees(int n) {
        int[] gn = new int[n+1];
        gn[0] = 1;
        gn[1] = 1;
        for (int i = 2; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                gn[i] += gn[j - 1] * gn[i - j];
            }
        }
       return gn[n];
    }
}
